﻿#include "FITKAbaqusAdaptorConnectorSection.h"
#include "InpKeyLineSpliter.h"
#include "FITKAbaqusINPReader.h"
#include "FITKAbaqusINPWriter.h"
#include "InpWriteInformationMapper.h"
#include "InpReadInformationMapper.h"
#include "FITKAbaqusAdaptorConnectorDampingBehavior.h"
#include "FITKAbaqusAdaptorConnectorElasticityBehavior.h"
#include "FITKAbaqusAdaptorConnectorLockBehavior.h"
#include "FITKAbaqusAdaptorConnectorPlasticityBehavior.h"
#include "FITKAbaqusAdaptorConnectorStopBehavior.h"
#include "FITK_Kernel/FITKCore/FITKEnumTransformer.hpp"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAssembly.h"
#include "FITK_Component/FITKAbaqusData/FITKAbaqusPart.h"
#include "FITK_Interface/FITKInterfaceModel/FITKAbstractAssInstance.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorSection.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorAssignment.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorBehaviorElasticity.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorBehaviorPlasticity.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorBehaviorDamping.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorBehaviorStop.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorBehaviorLock.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaTransform.h"
#include "FITK_Interface/FITKInterfaceModel/FITKModelSet.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaWire.h"
#include "FITK_Interface/FITKInterfaceModel/FITKAssElement.h"
#include <QDebug>
//命名空间
namespace IO
{
    QString FITKAbaqusAdaptorConnectorSection::getAdaptorClass()
    {
        return "IO::FITKAbaqusAdaptorConnectorSection";
    }

    void FITKAbaqusAdaptorConnectorSection::setConnectorAssignmentModelData(Interface::FITKAbaConnectorAssignment* assignData, Interface::FITKAbstractModel* modelData)
    {
        _connectAssignData = assignData;
        _modelData = modelData;
    }

    void FITKAbaqusAdaptorConnectorSection::setWriteBehavior(bool writeBehavior)
    {
        _writeBehavior = writeBehavior;
    }

    void FITKAbaqusAdaptorConnectorSection::setWriteElementId(int* writeElementId)
    {
        _writeElementId = writeElementId;
    }

    bool FITKAbaqusAdaptorConnectorSection::adaptR()
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_reader)return false;
        //回退一行，处理关键字信息
        _reader->backLine();
        QString line = _reader->readLine();
        //处理数据
        InpKeyLineSpliter s(line, _reader);
        QString sH = s.getHeader().toLower();
        bool readOK = false;
        if (sH == "connector section")
            readOK = this->readConnectSection();
        else if (sH == "connector behavior")
            readOK = this->readConnectSectionBehavior();
        return true;
    }

    bool FITKAbaqusAdaptorConnectorSection::adaptW()
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_writer)return false;
        bool writeOK = false;
        if (_writeBehavior)
            writeOK = this->writeConnectSectionBehavior();
        else
            writeOK = this->writeConnectSection();
        return true;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectSection()
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_reader || !_connectAssignData)return false;
        //回退一行，处理关键字信息
        _reader->backLine();
        QString line = _reader->readLine();
        //处理数据
        InpKeyLineSpliter s(line, _reader);
        //读取集合名称
        QString elset = s["elset"];
        //读取行为名称
        QString behavior = s["behavior"];
        sectionData->setDataObjectName(behavior);
        //读取section的选择类型
        line = _reader->readLine();
        if (!this->readConnectSectionType(line))
            return false;
        //读取坐标系
        line = _reader->readLine();
        QString csysName1, csysName2;
        if (!line.startsWith("*"))
        {
            QStringList str = line.split(',');
            if (str.isEmpty())return false;
            //获取坐标系1的名称
            csysName1 = "Ori_" + str.at(0).trimmed();
            if (csysName1.isEmpty())return false;
            //获取坐标系2的名称
            if (str.size() > 1 && !str.at(1).trimmed().isEmpty())
                csysName2 = "Ori_" + str.at(1).trimmed();
        }
        //获取映射表
        InpReadInformationMapper* mapper = _reader->getReadInpInformationMapper();
        if (!mapper)return false;
        //创建信息
        InpConnectorSectionAssignInfo* info = new InpConnectorSectionAssignInfo;
        info->_sectionData = sectionData;
        info->_elset = elset;
        info->_behavior = behavior;
        info->_csysName1 = csysName1;
        info->_csysName2 = csysName2;
        mapper->insertConnectorAssignment(_connectAssignData, info);
        return true;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectSection()
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_writer || !_connectAssignData || !_modelData)return false;
        //写出Element
        if (!this->writeElementCONN3D2())return false;
        QTextStream* stream = _writer->getStream();
        //写出Connector Section
        QString elesetName = _connectAssignData->getModelName();
        elesetName = elesetName.contains(' ') ? QString("\"%1\"").arg(elesetName) : elesetName;
        QString lineOne = QString("*Connector Section, elset=%1").arg(elesetName);
        if (!sectionData->getAllBehaviors().isEmpty())
        {
            QString behaviorName = sectionData->getDataObjectName();
            behaviorName = behaviorName.contains(' ') ? QString("\"%1\"").arg(behaviorName) : behaviorName;
            lineOne += QString(", behavior=%1").arg(behaviorName);
        }
        *stream << lineOne << endl;
        //写出section的选择的类型
        if (!this->writeConnectSectionType())return false;
        //获取坐标系id
        int csysId1 = _connectAssignData->getCsysId1();
        int csysId2 = _connectAssignData->getCsysId2();
        //获取装配
        Interface::FITKAbaAssembly* assemblyData = dynamic_cast<Interface::FITKAbaAssembly*>(_modelData);
        if (!assemblyData)return false;
        //获取坐标系管理
        Interface::FITKAbaTransformManager* fransformManager = assemblyData->getTransformManager();
        if (!fransformManager)return false;
        //写出坐标系
        Interface::FITKAbaTransform* csysData1 = fransformManager->getDataByID(csysId1);
        if (!csysData1)return false;
        QString csysName1 = csysData1->getDataObjectName();
        csysName1 = csysName1.contains(' ') ? QString("\"%1\"").arg(csysName1) : csysName1;
        Interface::FITKAbaTransform* csysData2 = fransformManager->getDataByID(csysId2);
        if (csysData2)
        {
            QString csysName2 = csysData2->getDataObjectName();
            csysName2 = csysName2.contains(' ') ? QString("\"%1\"").arg(csysName2) : csysName2;
            *stream << QString("%1, %2").arg(csysName1).arg(csysName2) << endl;
        }
        else
            *stream << QString("%1,").arg(csysName1) << endl;
        return true;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeElementCONN3D2()
    {
        if (!_writer || !_connectAssignData)return false;
        QTextStream* stream = _writer->getStream();
        //获取集合
        Interface::FITKModelSet* set = _connectAssignData->getTModelObj<Interface::FITKModelSet>();
        if (!set)return false;
        //获取装配
        Interface::FITKAbaAssembly* assemblyData = dynamic_cast<Interface::FITKAbaAssembly*>(_modelData);
        if (!assemblyData)return false;
        int modelId = _modelData->getDataObjectID();
        //获取线管理器
        Interface::FITKAbaWireManager* wireManager = assemblyData->getWireManager();
        if (!wireManager)return false;
        //获取映射
        InpWriteInformationMapper* mapper = _writer->getWriteInpInformationMapper();
        //获取单元类型的集合
        QList<Interface::FITKModelSet*> setList;
        set->getAbsoluteSet(setList, Interface::FITKModelEnum::FITKModelSetType::FMSElem);
        *stream << "*Element, type=CONN3D2" << endl;
        for (Interface::FITKModelSet* setData : setList)
        {
            QList<int> idElementList = setData->getAbsoluteMember();
            for (int elementId : idElementList)
            {
                Interface::FITKAbaAssEleCONN3D2* elementData = dynamic_cast<Interface::FITKAbaAssEleCONN3D2*>(wireManager->getElementByID(elementId));
                if (!elementData)return false;
                int instanceId1, instanceId2, nodeId1, nodeId2;
                elementData->getNode1(instanceId1, nodeId1);
                elementData->getNode2(instanceId2, nodeId2);
                QString nodeText1 = QString::number(nodeId1);
                QString nodeText2 = QString::number(nodeId2);
                if (instanceId1 != modelId && assemblyData)
                {
                    Interface::FITKAbstractAssInstance* instanceData = assemblyData->getDataByID(instanceId1);
                    if (instanceData)
                    {
                        QString instanceName = instanceData->getDataObjectName();
                        instanceName = instanceName.contains(' ') ? QString("\"%1\"").arg(instanceName) : instanceName;
                        nodeText1 = QString("%1.%2").arg(instanceName).arg(nodeId1);
                    }
                }
                if (instanceId2 != modelId && assemblyData)
                {
                    Interface::FITKAbstractAssInstance* instanceData = assemblyData->getDataByID(instanceId2);
                    if (instanceData)
                    {
                        QString instanceName = instanceData->getDataObjectName();
                        instanceName = instanceName.contains(' ') ? QString("\"%1\"").arg(instanceName) : instanceName;
                        nodeText2 = QString("%1.%2").arg(instanceName).arg(nodeId2);
                    }  
                }
                *stream << QString("%1, %2, %3").arg(++(*_writeElementId)).arg(nodeText1).arg(nodeText2) << endl;
                if(mapper)
                    mapper->insertConnectElement(elementId, *_writeElementId);
            }
        }
        return true;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectSectionType(QString line)
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_reader)return false;
        QStringList str = line.trimmed().toLower().split(',');
        if (str.isEmpty())return false;
        QString type1 = str.at(0).trimmed();
        QString type2;
        if (str.size() > 1)
            type2 = str.at(1).trimmed();
        if (type1 == "beam" || type1 == "cylindrical" || type1 == "hinge")
        {
            //AssembledComplexType
            sectionData->setCategory(Interface::FITKAbaConnectorSection::Category::AssembledComplex);
            if (type1 == "beam")
                sectionData->setAssebledComplexType(Interface::FITKAbaConnectorSection::AssembledComplexType::Beam);
            else if (type1 == "cylindrical")
                sectionData->setAssebledComplexType(Interface::FITKAbaConnectorSection::AssembledComplexType::Cylindrical);
            else if (type1 == "hinge")
                sectionData->setAssebledComplexType(Interface::FITKAbaConnectorSection::AssembledComplexType::Hinge);
            return true;
        }
        if (type1 == "axial" || type1 == "cartesian")
        {
            sectionData->setCategory(Interface::FITKAbaConnectorSection::Category::Basic);
            //TranslationalType
            if (type1 == "axial")
                sectionData->setTranslationalType(Interface::FITKAbaConnectorSection::TranslationalType::Axial);
            else if (type1 == "cartesian")
                sectionData->setTranslationalType(Interface::FITKAbaConnectorSection::TranslationalType::Cartesian);
            //RotationalType
            if (type2.isEmpty())
                sectionData->setRotationalType(Interface::FITKAbaConnectorSection::RotationalType::NoneRotational);
            else if (type2 == "cardan")
                sectionData->setRotationalType(Interface::FITKAbaConnectorSection::RotationalType::Cardan);
            else
                return false;
            return true;
        }
        if (type1 == "cardan")
        {
            sectionData->setCategory(Interface::FITKAbaConnectorSection::Category::Basic);
            //TranslationalType
            sectionData->setTranslationalType(Interface::FITKAbaConnectorSection::TranslationalType::NoneTranslational);
            //RotationalType
            if (type1 == "cardan")
                sectionData->setRotationalType(Interface::FITKAbaConnectorSection::RotationalType::Cardan);
            else
                return false;
            return true;
        }
        return false;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectSectionType()
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_writer)return false;
        QTextStream* stream = _writer->getStream();
        //获取类型
        Interface::FITKAbaConnectorSection::Category categoryType = sectionData->getCategory();
        if (categoryType == Interface::FITKAbaConnectorSection::Category::AssembledComplex)
        {
            //AssembledComplexType
            Interface::FITKAbaConnectorSection::AssembledComplexType assembledComplexType = sectionData->getAssembledComplexType();
            QString strType;
            if (assembledComplexType == Interface::FITKAbaConnectorSection::AssembledComplexType::Beam)
                strType = "Beam";
            else if (assembledComplexType == Interface::FITKAbaConnectorSection::AssembledComplexType::Cylindrical)
                strType = "Cylindrical";
            else if (assembledComplexType == Interface::FITKAbaConnectorSection::AssembledComplexType::Hinge)
                strType = "Hinge";
            if (strType.isEmpty())return false;
            *stream << QString("%1,").arg(strType) << endl;
        }
        else if (categoryType == Interface::FITKAbaConnectorSection::Category::Basic)
        {
            //RotationalType
            Interface::FITKAbaConnectorSection::RotationalType rotationalType = sectionData->getRotationalType();
            QString strTypeRotational;
            if (rotationalType == Interface::FITKAbaConnectorSection::RotationalType::Cardan)
                strTypeRotational = "Cardan";
            //TranslationalType
            Interface::FITKAbaConnectorSection::TranslationalType translationalType = sectionData->getTranslationalType();
            QString strTypeTranslational;
            if (translationalType == Interface::FITKAbaConnectorSection::TranslationalType::Axial)
                strTypeTranslational = "Axial";
            else if (translationalType == Interface::FITKAbaConnectorSection::TranslationalType::Cartesian)
                strTypeTranslational = "Cartesian";

            if (strTypeTranslational.isEmpty())
            {
                *stream << QString("%1,").arg(strTypeRotational) << endl;
            }
            else if (strTypeRotational.isEmpty())
            {
                *stream << QString("%1,").arg(strTypeTranslational) << endl;
            }
            else
            {
                *stream << QString("%1, %2").arg(strTypeTranslational).arg(strTypeRotational) << endl;
            }
        }
        return true;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectSectionBehavior()
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_reader)return false;
        
        //读取行为类型
        while (!_reader->atEnd())
        {
            bool ok = false;
            //读取一行，处理关键字信息
            QString line = _reader->readLine();
            //处理数据
            InpKeyLineSpliter s(line, _reader);
            QString sH = s.getHeader().toLower();
            //弹性
            if (sH == "connector elasticity")
                ok = this->readConnectElasticityBehavior();
            //阻尼
            else if (sH == "connector damping")
                ok = this->readConnectDampingBehavior();
            //塑性
            else if (sH == "connector plasticity")
                ok = this->readConnectPlasticityBehavior();
            //停止
            else if (sH == "connector stop")
                ok = this->readConnectStopBehavior();
            //锁定
            else if (sH == "connector lock")
                ok = this->readConnectLockBehavior();
            else if (line.startsWith("*"))
                return true;
            if (ok)
                _reader->backLine();
        }
        return false;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectSectionBehavior()
    {
        //获取数据
        Interface::FITKAbaConnectorSection* sectionData = dynamic_cast<Interface::FITKAbaConnectorSection*>(_dataObj);
        if (!sectionData || !_writer)return false;
        QString connBevrName = sectionData->getDataObjectName();
        connBevrName = connBevrName.contains(' ') ? QString("\"%1\"").arg(connBevrName) : connBevrName;
        QTextStream* stream = _writer->getStream();
        *stream << QString("*Connector Behavior, name=%1").arg(connBevrName) << endl;
        QList<Interface::FITKAbaConnectorBehavior *> behaviorList = sectionData->getAllBehaviors();
        for (Interface::FITKAbaConnectorBehavior* behaviorData : behaviorList)
        {
            bool writeOK = false;
            Interface::FITKAbaConnectorBehaviorEnum::ConnectorBehaviorType type = behaviorData->getBehaviorType();
            if (type == Interface::FITKAbaConnectorBehaviorEnum::ConnectorBehaviorType::Elasticity)
                writeOK = this->writeConnectElasticityBehavior(behaviorData);
            else if (type == Interface::FITKAbaConnectorBehaviorEnum::ConnectorBehaviorType::Damping)
                writeOK = this->writeConnectDampingBehavior(behaviorData);
            else if (type == Interface::FITKAbaConnectorBehaviorEnum::ConnectorBehaviorType::Plasticity)
                writeOK = this->writeConnectPlasticityBehavior(behaviorData);
            else if (type == Interface::FITKAbaConnectorBehaviorEnum::ConnectorBehaviorType::Stop)
                writeOK = this->writeConnectStopBehavior(behaviorData);
            else if (type == Interface::FITKAbaConnectorBehaviorEnum::ConnectorBehaviorType::Lock)
                writeOK = this->writeConnectLockBehavior(behaviorData);
            if (!writeOK)return false;
        }
        return true;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectElasticityBehavior()
    {
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorElasticityBehavior>("INP", "Interface::FITKAbaConnectorBehaviorElasticity");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置读取器
        adaptor->setFileReader(_reader);
        adaptor->setDataObject(_dataObj);
        bool ok = adaptor->adaptR();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectElasticityBehavior(Interface::FITKAbaConnectorBehavior* behaviorData)
    {
        Interface::FITKAbaConnectorBehaviorElasticity* elasticityData = dynamic_cast<Interface::FITKAbaConnectorBehaviorElasticity*>(behaviorData);
        if (!elasticityData)return false;
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorElasticityBehavior>("INP", "Interface::FITKAbaConnectorBehaviorElasticity");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置写出器
        adaptor->setFileWriter(_writer);
        adaptor->setDataObject(_dataObj);
        adaptor->setWriteBehaviorData(elasticityData);
        bool ok = adaptor->adaptW();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectDampingBehavior()
    {
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorDampingBehavior>("INP", "Interface::FITKAbaConnectorBehaviorDamping");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置读取器
        adaptor->setFileReader(_reader);
        adaptor->setDataObject(_dataObj);
        bool ok = adaptor->adaptR();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectDampingBehavior(Interface::FITKAbaConnectorBehavior* behaviorData)
    {
        Interface::FITKAbaConnectorBehaviorDamping* dampingData = dynamic_cast<Interface::FITKAbaConnectorBehaviorDamping*>(behaviorData);
        if (!dampingData)return false;
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorDampingBehavior>("INP", "Interface::FITKAbaConnectorBehaviorDamping");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置写出器
        adaptor->setFileWriter(_writer);
        adaptor->setDataObject(_dataObj);
        adaptor->setWriteBehaviorData(dampingData);
        bool ok = adaptor->adaptW();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectPlasticityBehavior()
    {
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorPlasticityBehavior>("INP", "Interface::FITKAbaConnectorBehaviorPlasticity");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置读取器
        adaptor->setFileReader(_reader);
        adaptor->setDataObject(_dataObj);
        bool ok = adaptor->adaptR();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectPlasticityBehavior(Interface::FITKAbaConnectorBehavior* behaviorData)
    {
        Interface::FITKAbaConnectorBehaviorPlasticity* plasticityData = dynamic_cast<Interface::FITKAbaConnectorBehaviorPlasticity*>(behaviorData);
        if (!plasticityData)return false;
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorPlasticityBehavior>("INP", "Interface::FITKAbaConnectorBehaviorPlasticity");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置写出器
        adaptor->setFileWriter(_writer);
        adaptor->setDataObject(_dataObj);
        adaptor->setWriteBehaviorData(plasticityData);
        bool ok = adaptor->adaptW();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectStopBehavior()
    {
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorStopBehavior>("INP", "Interface::FITKAbaConnectorBehaviorStop");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置读取器
        adaptor->setFileReader(_reader);
        adaptor->setDataObject(_dataObj);
        bool ok = adaptor->adaptR();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectStopBehavior(Interface::FITKAbaConnectorBehavior* behaviorData)
    {
        Interface::FITKAbaConnectorBehaviorStop* stopData = dynamic_cast<Interface::FITKAbaConnectorBehaviorStop*>(behaviorData);
        if (!stopData)return false;
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorStopBehavior>("INP", "Interface::FITKAbaConnectorBehaviorStop");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置写出器
        adaptor->setFileWriter(_writer);
        adaptor->setDataObject(_dataObj);
        adaptor->setWriteBehaviorData(stopData);
        bool ok = adaptor->adaptW();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::readConnectLockBehavior()
    {
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorLockBehavior>("INP", "Interface::FITKAbaConnectorBehaviorLock");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置读取器
        adaptor->setFileReader(_reader);
        adaptor->setDataObject(_dataObj);
        bool ok = adaptor->adaptR();

        delete adaptor;
        return ok;
    }

    bool FITKAbaqusAdaptorConnectorSection::writeConnectLockBehavior(Interface::FITKAbaConnectorBehavior* behaviorData)
    {
        Interface::FITKAbaConnectorBehaviorLock* lockData = dynamic_cast<Interface::FITKAbaConnectorBehaviorLock*>(behaviorData);
        if (!lockData)return false;
        //通过工厂创建
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusAdaptorConnectorLockBehavior>("INP", "Interface::FITKAbaConnectorBehaviorLock");
        if (adaptor == nullptr)
        {
            return false;
        }
        //设置写出器
        adaptor->setFileWriter(_writer);
        adaptor->setDataObject(_dataObj);
        adaptor->setWriteBehaviorData(lockData);
        bool ok = adaptor->adaptW();

        delete adaptor;
        return ok;
    }
}